//
//  ViewController.m
//  WJCommon-master
//
//  Created by Yunhai.Wu on 15/11/18.
//  Copyright © 2015年 WJ. All rights reserved.
//

#import "ViewController.h"
#import "QWLoggingMacros.h"

@interface ViewController ()

@end

@implementation ViewController

-(void) rightBarBtnItemExec:(id)sender {
    NSLog(@"RIGHT EXEC");
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.qwNavBarStatus = QWNavBarStatusTranslucent;
//    QWLogWarn(@"error");
//    QWLogWarn(@"warn");
//    QWLogInfo(@"info");
//    QWLogDebug(@"debug");
//    QWLogVerbose(@"verbose");
//    [self.navigationController setNavigationBarHidden:YES];
    [self.qwView setBackgroundColor:[UIColor grayColor]];
    
    self.qwNavTitle = @"TestKKKKKK";
    
    [self.qwNavigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"tttttt" style:UIBarButtonItemStylePlain target:self action:@selector(rightBarBtnItemExec:)]];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setTitle:@"Button" forState:UIControlStateNormal];
    [btn setFrame:CGRectMake((self.view.bounds.size.width-50.0f)/2, (self.view.bounds.size.height-50.0f)/2, 50.0f, 50.0f)];
    [btn setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin];
    [btn addTarget:self action:@selector(btnOnClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
}

-(UIRectEdge)edgesForExtendedLayout {
    return UIRectEdgeAll;
}

-(void) btnOnClicked {
    [self.navigationController pushViewController:[[ViewController alloc] init] animated:YES];
}

-(void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    NSLog(@"%@ : %@",NSStringFromCGRect(self.qwNavigationBar.frame),NSStringFromCGRect(self.qwView.frame));
}

-(NSDictionary *)qw_navBarStatusAttributesDict {
    NSShadow *shadow = [[NSShadow alloc] init];
    [shadow setShadowOffset:CGSizeMake(0, 0)];
    [shadow setShadowColor:[UIColor clearColor]];
    QWNavBarStatusAttributes *translucentStatus = [[QWNavBarStatusAttributes alloc] initTintColor:[UIColor yellowColor]
                                                                   barBackgroundImage:[[UIImage alloc] init]
                                                                          shadowImage:[[UIImage alloc] init]
                                                                        isTranslucent:YES
                                                                  titleTextAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:17],
                                                                                        NSForegroundColorAttributeName:[UIColor whiteColor],
                                                                                        NSShadowAttributeName: shadow}
                                                                       statusBarStyle:UIStatusBarStyleLightContent];
    
    
    QWNavBarStatusAttributes *nonTranslucentStatus = [[QWNavBarStatusAttributes alloc] initTintColor:[UIColor redColor]
                                                                      barBackgroundImage:[[UIImage imageNamed:@"nav-bar"] stretchableImageWithLeftCapWidth:10 topCapHeight:10]
                                                                             shadowImage:nil
                                                                           isTranslucent:NO
                                                                     titleTextAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:17],
                                                                                           NSForegroundColorAttributeName:[UIColor redColor],
                                                                                           NSShadowAttributeName: shadow}
                                                                          statusBarStyle:UIStatusBarStyleDefault];
    
    return @{@(QWNavBarStatusNonTranslucent):nonTranslucentStatus,@(QWNavBarStatusTranslucent):translucentStatus};
    
}

@end
